package com.xm_jd.controller.dd;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xm_jd.model.dao.index6Dao;
import com.xm_jd.model.entitys.tb_sh;
import com.xm_jd.utils.BaseServlet;

/**
 * Servlet implementation class index6_addadreess
 */
@WebServlet("/index6_addadreess")
public class index6_addadreess extends BaseServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public index6_addadreess() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 设置字符集
		request.setCharacterEncoding("utf-8");
		String shuor = request.getParameter("shuor");
		String xiadi = request.getParameter("xiadi");
		String phonea = request.getParameter("phonea");
		String ss = request.getParameter("ssq");
		// 从session取用户名
		request.getSession().getAttribute("user");
		
		if (shuor != null && xiadi != null && phonea != null && ss != null) {
			tb_sh shiti = new tb_sh();
			shiti.setSh_name(shuor);
			shiti.setSh_xxdz(xiadi);
			shiti.setSh_phone(phonea);
			shiti.setSh_address(ss);
			shiti.setSh_ismr("0");
			shiti.setSh_user_id(1);

			new index6Dao().addgood(shiti);

			request.getSession().getAttribute("user");

			List<tb_sh> list = new index6Dao().selectSh(1);
			request.getSession().setAttribute("address", list);
		}

		//response.sendRedirect("index6");
		this.redirect("/index6");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
